package com.jjyu.controller;

import com.jjyu.entity.Result;
import com.jjyu.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
@RequestMapping("/orders")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/create")
    public Result<String> createOrder(@RequestParam Integer userId, @RequestBody HashMap<Integer, Integer> orderItems) {
        if (orderService.createOrder(userId, orderItems)) {
            return Result.success("create order success");
        }
        return Result.error("create order failed");
    }
}
